package com.king.springcloud.controller;

import com.king.springcloud.entities.CommonResult;
import com.king.springcloud.entities.PaymentEntity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author king
 * @date 2020/10/19 19:52
 */
@RestController
public class PaymentController {

    @Value("${server.port}")
    private String serverPort;

    public static Map<Long, PaymentEntity> map = new HashMap<Long, PaymentEntity>() {{
        put(1L, new PaymentEntity(1L, "11111111"));
        put(2L, new PaymentEntity(2L, "22222222"));
        put(3L, new PaymentEntity(3L, "33333333"));
    }};

    @GetMapping("/paymentSQL/{id}")
    public CommonResult<PaymentEntity> paymentSQL(@PathVariable("id") Long id) {
        return new CommonResult<>(200, "from mysql, serverPort: " + serverPort, map.get(id));
    }
}
